package com.work.test;

import java.util.Scanner;

public class T11 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        b = b % a;
        int[] nums = new int[a];
        for (int i = 0; i < a; i++){
            nums[i] = scanner.nextInt();
        }

        int start = 0;
        for (int j = a-b; start < b ;start++,j++){
            System.out.print(nums[j]+" ");
        }

        for (int i = 0;i < a-b;i++){
            if (i == a-b-1){
                System.out.println(nums[i]);
                break;
            }
            System.out.print(nums[i]+" ");
        }
    }
}
